package com.oraclechain.pocketeos.utils;

import android.content.Context;

/**
 * Created by pocketEos on 2017/11/23.
 * Utils初始化相关
 */
public final class Utils {

    private static Context context;
    private static SPUtils spUtils;


    private Utils() {
        throw new UnsupportedOperationException("...");
    }

    /**
     * 初始化工具类
     *
     * @param context 上下文
     */
    public static void init(Context context) {
        Utils.context = context.getApplicationContext();
        spUtils = new SPUtils("USER");
    }

    /**
     * 获取ApplicationContext
     *
     * @return ApplicationContext context
     */
    public static Context getContext() {
        if (context != null) {
            return context;
        }
        throw new NullPointerException("应该首先初始化");
    }

    /**
     * Gets sp utils.
     *
     * @return the sp utils
     */
    public static SPUtils getSpUtils() {
        return spUtils;
    }

    /**
     * 重启整个APP
     * @param Delayed 延迟多少毫秒
     */
    public static void restartAPP(long Delayed){

//        /**开启一个新的服务，用来重启本APP*/
//        Intent intent1=new Intent(context,KillSelfService.class);
//        intent1.putExtra("PackageName",context.getPackageName());
//        intent1.putExtra("Delayed",Delayed);
//        context.startService(intent1);
//
//        /**杀死整个进程**/
//        android.os.Process.killProcess(android.os.Process.myPid());
    }



}
